package com.bupt.liutong.admin.sch.dao;

import java.util.List;

import com.bupt.liutong.admin.core.base.Ibatis;
import com.bupt.liutong.admin.core.base.Photo;
import com.bupt.liutong.admin.core.base.PhotoDao;
import com.bupt.liutong.admin.sch.dto.TeacherPhoto;

public class TeacherPhotoDao implements PhotoDao {

	private Ibatis ibatis;
	
	@SuppressWarnings("unchecked")
	public List<TeacherPhoto> getTeacherPhotosByTeacherId(Integer teacherId){
		return (List<TeacherPhoto>) ibatis.queryForList("sch_teacher_photo.getTeacherPhotosByTeacherId", teacherId);
	}

	public TeacherPhoto getTeacherPhotoById(Integer id){
		return (TeacherPhoto) ibatis.queryForObject("sch_teacher_photo.getTeacherPhotoById", id);
	}
	
	public void insertTeacherPhoto(TeacherPhoto teacherPhoto){
		ibatis.insert("sch_teacher_photo.insertTeacherPhoto", teacherPhoto);
	}
	
	public void updateTeacherPhoto(TeacherPhoto teacherPhoto){
		ibatis.insert("sch_teacher_photo.updateTeacherPhoto", teacherPhoto);
	}
	
	public void deleteTeacherPhoto(Integer id){
		ibatis.insert("sch_teacher_photo.deleteTeacherPhoto", id);
	}

	public void setIbatis(Ibatis ibatis) {
		this.ibatis = ibatis;
	}

	public void insertPhoto(Photo uploadDto) {
		this.insertTeacherPhoto((TeacherPhoto) uploadDto);
	}

	public Photo deletePhoto(Integer id) {
		TeacherPhoto teacherPhoto = this.getTeacherPhotoById(id);
		this.deleteTeacherPhoto(id);
		return teacherPhoto;
	}

	public void updatePhoto(Photo photo) {
		this.updateTeacherPhoto((TeacherPhoto) photo);
	}
}
